package com.qidianit.mes.md.controller;

import com.qidianit.common.pojo.MESResult;
import com.qidianit.mes.md.service.WorkstationService;
import com.qidianit.mes.pojo.Workstation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 奇幻夜之梦
 * @Company 起点编程
 * @Description
 * @Time 2024/10/25 23:03
 */
@CrossOrigin // 允许跨域请求
@RestController
@RequestMapping("/workstation")
public class WorkstationController {
    @Autowired
    private WorkstationService workstationService;
    @GetMapping("/list")
    public MESResult selectByPage(Workstation workstation,
                                  @RequestParam(defaultValue = "1")int page,
                                  @RequestParam(defaultValue = "10")int limit){
        // 这里只有一行代码，直接调用service，不处理任何业务
        return workstationService.selectByPage(workstation,page,limit);
    }
    @PostMapping("/save")
    public MESResult save(@RequestBody Workstation workstation) {
        return  workstationService.save(workstation);
    }

    @PutMapping("/update")
    public MESResult update(@RequestBody Workstation workstation) {
        return workstationService.updateWorkstation(workstation);
    }

    @GetMapping("selectById")
    public MESResult selectById(Long workstationId) {
        return workstationService.selectById(workstationId);
    }

    @DeleteMapping("/delete")
    public MESResult delete(Long workstationId){
        return workstationService.delete(workstationId);
    }

    @DeleteMapping("/deletes")
    public MESResult deletes(String [] workstationId){
        return workstationService.deletes(workstationId);
    }

    @GetMapping("/listWorkShops")
    public MESResult listWorkstations() {
        return workstationService.listWorkstations();
    }
}

